package com.yuandian.api.business_monitor.vo;

import com.yuandian.api.management.vo.EndToEndNodeVo;
import com.yuandian.utils.IpUtils;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * 说明：网端详情数据vo对象
 * @Author yanjun
 * @Date 2020/9/7 10:58
 */
@Data
public class SegmentDetail {

    /**
     * 数据id
     */
    private String dataId;

    /**
     * 数据类型
     */
    private String dataType;

    /**
     * 网端id
     */
    private Integer segmentId;

    /**
     * 网端名称
     */
    private String segmentName;

    /**
     * 服务资源编码集合
     */
    private List<String> resourceCodes;

    /**
     * id集合
     */
    private List<String> preRelvanceIds;

    /**
     * 组件集
     * ip:端口
     */
    private List<String> components;

    /**
     * 坐标X
     */
    private Double locationX;

    /**
     * 坐标Y
     */
    private Double locationY;

    /**
     * 首端标识
     * 1：首端
     * 2：非首端
     */
    private Integer headerFlag = 0;

    /**
     * 标识
     */
    private Integer oneFlag = 0;

    /**
     * 成功数(和dealState有关)
     */
    private Integer successCount;

    /**
     * 成功率
     */
    private Float successRate;

    /**
     * 状态
     */
    private String state;

    /**
     * 健康数
     */
    private Integer healthCount;

    /**
     * IP端口
     */
    private String ipPort;

    /**
     * 开始时间
     */
    private String startTime;

    /**
     * 结束时间
     */
    private String endTime;

    /**
     * 开始时间戳
     */
    private Long startTimeUsec;

    /**
     * 结束时间戳
     */
    private Long endTimeUsec;

    /**
     * 处理时长
     */
    private Float dealTime;

    /**
     * 客户端传输时长
     */
    private Float clientTransTime;

    /**
     * 服务端传输时长
     */
    private Float serverTransTime;

    /**
     * 服务器响应时长
     */
    private Float serverResponseTime;

    /**
     * 服务器响应开始时间
     */
    private String serverResponseStartTime;

    /**
     * 服务器响应结束时间
     */
    private String serverResponseEndTime;

    /**
     * 服务器响应开始时间戳
     */
    private Long serverResponseStartTimeUsec;

    /**
     * 服务器响应结束时间戳
     */
    private Long serverResponseEndTimeUsec;

    /**
     * 时间范围合并结果集
     */
    private List<Map<String, Object>> mergeTimeRangeList;

    /**
     * 平均网络传输耗时
     */
    private Float averageNetTransTime;

    /**
     * 请求mac
     */
    private String requestMac;

    /**
     * 响应mac
     */
    private String responseMac;

    private Long sumCount = 0L;

    private Integer dealCount;

    private String afterStartTime;

    private String afterEndTime;

    private Long afterStartTimeUsec;

    private Long afterEndTimeUsec;


    public void setRequestMac(String requestMac) {
        try {
            this.requestMac = IpUtils.longToMac(Long.valueOf(requestMac));
        }catch (Exception e){
            this.requestMac = requestMac;
        }

    }

    public void setResponseMac(String responseMac) {
        try {
            this.responseMac = IpUtils.longToMac(Long.valueOf(responseMac));
        }catch (Exception e){
            this.responseMac = responseMac;
        }
    }
}
